/*
   Copyright (c) 2019 Shanghai Xuanzi Technology Co. Ltd https://xuanzi.ltd
   XZMindMap is licensed under the Mulan PSL v1.
   You can use this software according to the terms and conditions of the Mulan PSL v1.
   You may obtain a copy of Mulan PSL v1 at:
      http://license.coscl.org.cn/MulanPSL
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
   PURPOSE.
   See the Mulan PSL v1 for more details.

*/

package xuanzi.openmind.nodes;

import xuanzi.commons.graphics.Canvas;
import xuanzi.commons.graphics.Line;
import xuanzi.commons.graphics.Paint;
import xuanzi.commons.graphics.Path;
import xuanzi.commons.graphics.PointF;
import xuanzi.commons.graphics.BoxF;
import xuanzi.openmind.layout.Box;
import xuanzi.openmind.lines.ArrorUtils;
import xuanzi.openmind.lines.ArrorUtils.ArrorInfo;

public class Contact extends Widget{
 
	Node a,b;
	
	
	
	
	public Contact(Node a,Node b) {
		this.a = a;
		this.b = b; 
	}
	
	public Contact() {
		label = "联 系";
	}
	
	Paint xpaint = new Paint();
	
	private float borderSize = 5f;
	
	 
	@Override
	public void draw(Canvas canvas) { 
		super.draw(canvas);
		BoxF start =a.getNodeBound();
		BoxF end = b.getNodeBound();
		paint.stroke(a.renderBuffer.borderColor,borderSize );
		
		Line line = Line.toRect(start, end); 
		path.reset();
		path.moveTo(line.a.x, line.a.y);
		path.cubicTo(line.a.x, (line.b.y+line.a.y)/2, line.b.x, (line.b.y+line.a.y)/2, line.b.x, line.b.y);
		ArrorInfo info = ArrorUtils.create(new PointF( line.b.x, (line.b.y+line.a.y)/2), line.b);
		ArrorUtils.paintArror0(path, info);
		canvas.drawPath(path, xpaint);
		System.out.println("draw line");
	}
	
	Path path = new Path();
	
	@Override
	public void onLayout(Box parent) {
		// TODO Auto-generated method stub
		super.onLayout(parent);
	}
	
	public void setA(Node a) {
		this.a = a;
	}
	
	public void setB(Node b) {
		this.b = b;
	}
	
	public Node getA() {
		return a;
	}
	
	public Node getB() {
		return b;
	}

}
